import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/*
 * @author zzr
 * @date: 2025/05/12  20:00
 * @description: InputStream 的 read 方法~
 */
public class Demo20 {
    public static void main(String[] args)  {

        try (InputStream inputStream = new FileInputStream("./test.txt")) {
            byte[] buffer = new byte[1024];

            while (true) {
                int n = inputStream.read(buffer);
                if (-1 == n) {
                    break;
                }
                String s = new String(buffer, 0, n);
                System.out.println(s);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
